﻿#include "QFrameBase.h"
#include "CAppUiConfig.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
QFrameBase::QFrameBase(QWidgetBase *parent) : QWidgetBase(parent)
{
	if(SETTING_WIDGET_FRAME_IS_SHOW_BORDER == 1){

		this->setObjectName("QFrameBase");
		this->setStyleSheet("#QFrameBase{background:transparent;border:5px solid rgb(0,255,255);}");
		return;
	}

	this->setObjectName("QFrameBase");
	this->setStyleSheet("#QFrameBase{background:transparent;}");
}

QFrameBase::~QFrameBase()
{
	
}

void QFrameBase::initUI()
{
	QWidgetBase::initUI();
	//超时定时器
	m_pQTimer = new QTimer(this);

}

//初始化信号关联
void QFrameBase::initConnect()
{
	QWidgetBase::initConnect();
	connect(m_pQTimer, SIGNAL(timeout()), this, SLOT(slotsTimerOut()));
}

// 启动
void QFrameBase::onStart()
{
	QWidgetBase::onStart();
	// 重置定时器
	timeReset();
	this->setFocus();

}

// 停止
void QFrameBase::onStop()
{
	QWidgetBase::onStop();
	timeStop();
}

// 获取页面超时（默认不超时）
int QFrameBase::getTimeOut()
{
	return -1;
}

// 重置超时
void QFrameBase::timeReset()
{
	int timeOut = getTimeOut();
	if(timeOut > 0)
		m_pQTimer->start(getTimeOut() * 1000);
}

// 停止定时器
void QFrameBase::timeStop()
{
	m_pQTimer->stop();
}

// 超时回调
void QFrameBase::slotsTimerOut()
{
	qDebug("QFrameBase::slotsTimerOut");
}

void QFrameBase::paintEvent(QPaintEvent *event)
{
	QWidgetBase::paintEvent(event);
	Q_UNUSED(event);

	QStyleOption opt;
	opt.init(this);
	QPainter p(this);
	style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
	if(m_upSize > 0){
		m_upSize--;
		update();
	}
}


//窗口大小发生变化自动调用虚函数
void QFrameBase::resizeEvent(QResizeEvent *event)
{
	
}


